// Gtk+-specific icon definition
// Copyright 2006 (C) Ralph Thomas

#ifndef MISSION_TOOLKIT_GTK_ICON_H
#define MISSION_TOOLKIT_GTK_ICON_H

#include <toolkit/icon.h>
#include <string>
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#include <gtk/os_utilities.hpp>

namespace toolkit {
	class icon_gtk {
		std::string	icon_name_m;
		GdkPixbuf*	preview_m;
	  public:
		icon_gtk( const std::string& icon_name, GdkPixbuf* preview = 0 );
		virtual ~icon_gtk();
		GdkPixbuf* get_pixbuf( long pixel_size ) const;
		void apply( GtkImage* image, GtkIconSize size ) const;
	};
	typedef boost::function<void ()> icon_receiver_t;
	//
	/// If the icon is available then it will be returned immediately,
	/// otherwise it will be scheduled to be loaded and the receiver
	/// function will be called once it's been loaded. At this point
	/// this function can be called again and a different icon will be
	/// returned.
	///
	/// \param	filename	the filename to get the icon of.
	/// \param	receiver	the function to call when the real icon has been loaded.
	//
	GdkPixbuf* get_icon(const std::string& filename, const icon_receiver_t& receiver);
	typedef boost::shared_ptr<icon_gtk> icon_gtk_ptr_t;
};

#endif

